import request from "@/utils/request";
import { stringify } from "qs";

const prefix = "/new-goods";
//获取列表分页
export async function queryPageSkuList(params) {
	return request(`${prefix}/ec-goods-sku/search-ecgoodssku-by-page?${stringify(params)}`, {
		loading: true
	});
}

export async function queryPageSpuList(params) {
	return request(`${prefix}/ec-goods-spu/search-ecgoodsspu-by-page?${stringify(params)}`, {
		loading: true
	});
}

//批量修改库存(线上库存)
export async function batchModifyOnlineInventory(params) {
	return request(`${prefix}/ec-goods-sku/stock/batch-update`, {
		method: "put",
		data: params,
		loading: false
	});
}
// 检索批量编辑商品编码的SKU数据
export async function batchModifyOnlineInventoryGetUpdateSkuList(params) {
	return request(`${prefix}/ec-goods-sku/codes/get-update-data-list?${stringify(params)}`, {
		loading: true
	});
}
//批量编辑商品编码
export async function batchModifyShopSkuCode(params) {
	return request(`${prefix}/ec-goods-sku/codes/batch-update`, {
		method: "put",
		data: params,
		loading: false
	});
}
//上传商品编码
export async function uploadSkuCodeToShop(params) {
	return request(`${prefix}/ec-goods-sku/codes/batch-upload`, {
		method: "post",
		data: params,
		loading: false
	});
}

//启/禁同步库存 SKU
export async function enableSkuSynchronizedInventory(params) {
	return request(`${prefix}/ec-goods-sku/stock/enable-sync`, {
		method: "post",
		data: params,
		loading: true
	});
}
//启/禁同步库存 SPU
export async function enableSpuSynchronizedInventory(params) {
	return request(`${prefix}/ec-goods-spu/stock/enable-sync`, {
		method: "post",
		data: params,
		loading: true
	});
}
// 手动同步库存 SKU
export async function batchSkuSynchronizedInventoryByHand(params) {
	return request(`${prefix}/ec-goods-sku/stock/batch-sync-stock-by-hand`, {
		method: "post",
		data: params,
		loading: false
	});
}
// 手动同步库存 SPU
export async function batchSpuSynchronizedInventoryByHand(params) {
	return request(`${prefix}/ec-goods-spu/stock/batch-sync-stock-by-hand`, {
		method: "post",
		data: params,
		loading: false
	});
}
// SKU上下架
export async function changeGoodsSkuCodeSaleStatus(params) {
	return request(`${prefix}/ec-goods-sku/sale-status`, {
		method: "post",
		data: params,
		loading: true
	});
}
// SPU上下架
export async function changeGoodsSpuCodeSaleStatus(params) {
	return request(`${prefix}/ec-goods-spu/sale-status`, {
		method: "post",
		data: params,
		loading: true
	});
}
// 店铺SKU批量删除
export async function batchDeleteGoodsSku(params) {
	return request(`${prefix}/ec-goods-sku/batch`, {
		method: "delete",
		data: params,
		loading: true
	});
}
// sn030 库存同步:查询批次进度  batchId
export async function getInventorySyncGetSchedule(params) {
	return request(`/new-3gw-goods/syncGoodsStockRecord/getStockSyncRecordLogPercent?${stringify(params)}`, {
		loading: false
	});
}

export async function manuallySynchronizeStoreProducts(params) {
	return request(`${prefix}/ec-goods-sku/sync-ec-goods-sku-by-hand?${stringify(params)}`, {
		loading: true
	});
}
// 查询平台店铺列表
export async function queryShopList(params) {
	const data = { current: 1, size: 100, ...params };
	return request(`/blade-goods/newSystem/ecStore/list/page`, {
		method: "POST",
		data: data
	});
}

// 匹配系统商品
export async function goodsShopSkuMatchSysSku(params) {
	return request(`/new-goods/ec-goods-sku/${params.id}/match-sys-sku`, {
		method: "POST",
		loading: true
	});
}
// sku日志
export async function getGoodsSkuLogPage(params) {
	return request(`/new-goods/logs/ec-goods-sku/page?${stringify(params)}`, {
		loading: true
	});
}
// spu日志
export async function getGoodsSpuLogPage(params) {
	return request(`/new-goods/logs/ec-goods-spu/page?${stringify(params)}`, {
		loading: true
	});
}
// 操作人列表
export async function getUserListByUuid(params) {
	return request(`/blade-user/user/getUserListByUuid`, {
		method: "post",
		data: params,
		loading: true
	});
}

// 生成系统商品
export async function createSysGoods(params) {
	return request(`/new-goods/ec-goods-sku/create-generate-sys-goods-by-hand-task`, {
		method: "post",
		data: params,
		loading: true
	});
}

// 获取生成的系统商品
export async function getCreatedSysGoods(params) {
	return request(`/new-goods/ec-goods-sku/query-generate-sys-goods-by-hand-task?${stringify(params)}`, {
		loading: false
	});
}
/***************************************************** */
